package elevatronic.view.left.floors;

import java.util.ArrayList;
import java.util.List;

import elevatronic.models.Floor;
import elevatronic.view.MPanel;

public class FloorPanels extends MPanel{
	private static final long serialVersionUID = 746822206509573950L;

	public static final int FLOOR_PANEL_POSX=10;
	public static final int FLOOR_PANEL_POSY=2;
	
	
	//List of floor panel
	private List<FloorPanel> floorPanels;
	public List<FloorPanel> getFloorPanels() {
		return floorPanels;
	}
	public void setFloorPanels(List<FloorPanel> floorPanels) {
		this.floorPanels = floorPanels;
	}
	
	//list of floors models
	private List<Floor> floors;
	public List<Floor> getFloors() {
		return floors;
	}
	public void setFloors(List<Floor> floors) {
		this.floors = floors;
	}
	
	
	/** 	
	 * Constructor
	 * @param wdth width of the panel
	 * @param hght height of the panel
	 */
	public FloorPanels(int wdth,int hght, List<Floor> floors){
		super(wdth,hght);
	    setFloors(floors);
	    List<FloorPanel> floorPanels=new ArrayList<FloorPanel>();
	    int i=0;
	    for(Floor floor:floors){
	    	FloorPanel floorPanel=new FloorPanel(FloorPanel.FLOOR_PANEL_WIDTH,FloorPanel.FLOOR_PANEL_HEIGHT,floor);
	    	floorPanel.setLocation(FLOOR_PANEL_POSX, FLOOR_PANEL_POSY+FloorPanel.FLOOR_PANEL_HEIGHT*i);
	    	floorPanels.add(floorPanel);
	    	add(floorPanel);
	    	i++;
	    }
	    setFloorPanels(floorPanels);
	}


	//iteration of the floor panels
	public void update(int step){
		super.update(step);
		for (FloorPanel floorPanel:getFloorPanels()){
			floorPanel.update(step);
		}
	}

}
